<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<JS href="../Public/js/jq.js" />
<CSS href="../Public/css/common.css" />
<script>
function add(id)
{
	$.post('__URL__/add_sch_spe',{
		'specialityid':id,
		'schoolid':'{.schoolid}'
	},function(){
		window.location.reload();
	})	
}
function del(id)
{
	$.post('__URL__/del_sch_spe',{
		'id':id	
		},function(){
		window.location.reload();
	})	
}
function edit(id)
{
window.open('__URL__/edit_sch_spe/id/'+id);
}

function checkall()
{
	$('.ctl').attr('checked','checked');
}
function addall()
{
	result = '';
	$('.ctl').each(function(i)
	{
		if($(this).attr('checked') == true)
		{
			if(result == '')
			{
				result = $(this).val();
			}else
			{
				result += ','+$(this).val();
			}
		}
	})
	
	$.post('__URL__/add_sch_spe',{
		'specialityid':result,
		'schoolid':'{.schoolid}'
	},function(){
		window.location.reload();
	})	
}
function delall()
{
	result = '';
	$('.ctl').each(function(i)
	{
		if($(this).attr('checked') == true)
		{
			if(result == '')
			{
				if($(this).attr('delid') != '')
				result = $(this).attr('delid');
			}else
			{
				if($(this).attr('delid') != '')
				result += ','+$(this).attr('delid');
			}
		}
	})
	
	$.post('__URL__/del_sch_spe',{
		'id':result,
	},function(){
		window.location.reload();
	})	
}

</script>
<style>
select{height:200px;}
select option{height:11px; line-height:11px; margin:0; padding:0; overflow:hidden; border:none;}
.top_class{background:#ddd; color:#333;}
</style>
</head>
<body>

<div class="spe_list">
<p>专业列表</p>
<table border="1">
<tr><td>&nbsp;</td><td>名称</td><td>是否本校专业</td><td>操作</td></tr>
<volist name="spe_arr" id="vo">
<tr class="top_class"><td colspan="4">{$vo.title}</td></tr>
<notempty name="vo.child">
<volist name="vo.child" id="vo2">
<tr><td><input type="checkbox" class="ctl" value="{$vo2.id}" delid="{$vo2.sch_id}" name="sel[]" /></td><td>--{$vo2.title}</td>
<td><present name="vo2.in_sch">是<else/>否</present></td>
<td><present name="vo2.in_sch"><input type="button" onclick="del('{$vo2.sch_id}')" value="删"/><input  type="button" onclick="edit('{$vo2.sch_id}')" value="改" /><else /><input type="button" value="加" onclick="add('{$vo2.id}')" /></present>
</td></tr>
</volist>

</notempty>

</volist>
</table>
<input type="button" onclick="checkall()" value="全选" /> <input type="button" onclick="addall()" value="全部添加" /> <input type="button" onclick="delall()" value="批量删除" />

</div>
</body>
</html>